﻿{layout name="layout" /}

<div class="Hui-article">
	<article class="cl pd-20">
		<p class="f-20 text-success">欢迎{$data.username}</p>
		<p>登录次数：{$lgcounts} </p>
		<p>此次登录IP：{$Think.session.lip|inet_ntoa} 此次登录时间：{$Think.session.ltime|date="Y-m-d H:i:s", ###}</p>
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-1" style="text-align:left;">
				我的邮箱：</label>
			<div class="formControls col-xs-4 col-sm-3">
				<input type="text" class="input-text" id="email" name="email" value="{$data.email}" disabled="true">
			</div>
			<div class="formControls col-xs-6 col-sm-3 col-md-2">
				<button class="btn btn-primary radius email" type="button" onClick="modify(this, 'email')" style="display:block;">修改</button>
				<button class="btn btn-success radius email" type="button" onClick="do_modify(this, 'email', '{$data.id}')" style="display:none;">确定</button>
				<button class="btn btn-deefault radius email" type="button" onClick="cancle(this, 'email', '{$data.id}')" style="display:none;">取消</button>
			</div>
		</div>
		<br />
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-1" style="text-align:left;">
				我的笔名：</label>
			<div class="formControls col-xs-4 col-sm-3">
				<input type="text" class="input-text" id="pen_name" name="pen_name" value="{$data.pen_name}" disabled="true">
			</div>
			<div class="formControls col-xs-6 col-sm-3 col-md-2">
				<button class="btn btn-primary radius pen_name" type="button" style="display:block;" onClick="modify(this, 'pen_name')">修改</button>
				<button class="btn btn-success radius pen_name" type="button" style="display:none;" onClick="do_modify(this, 'pen_name')">确定</button>
				<button class="btn btn-deefault radius pen_name" type="button" style="display:none;" onClick="cancle(this, 'pen_name')">取消</button>
			</div>
		</div>
		<p style='margin:10px 0;'>
			[ <a href="{:url('/admin_user/modifypwd')}" style="color:blue;">修改密码</a> ]
		</p>
		<table class="table table-border table-bordered table-bg" style="min-width:900px;max-width:90%;">
			<thead>
				<tr>
					<th colspan="7" scope="col">信息统计</th>
				</tr>
				<tr class="text-c">
					<th>统计</th>
					<th>资讯库</th>
					<th>图片库</th>
					<th>产品库</th>
					<th>用户</th>
					<th>管理员</th>
				</tr>
			</thead>
			<tbody>
				<tr class="text-c">
					<td>总数</td>
					<td>-</td>
					<td>-</td>
					<td>-</td>
					<td>-</td>
					<td>-</td>
				</tr>
			</tbody>
		</table>
		<table class="table table-border table-bordered table-bg mt-20" style="min-width:360px;max-width:38%;float:left;">
			<thead>
				<tr>
					<th colspan="2" scope="col">服务器信息</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>网站域名</td>
					<td>{$Think.server.http_host}</td>
				</tr>
				<tr>
					<td width="40%">服务器计算机名</td>
					<td>
						<span id="lbServerName">{$Think.server.server_name}</span>
					</td>
				</tr>
				<tr>
					<td>服务器IP地址</td>
					<td>{$Think.server.server_addr}</td>
				</tr>
				<tr>
					<td>服务器运行环境</td>
					<td>{$Think.php_os}</td>
				</tr>
				<tr>
					<td>WEB服务版本</td>
					<td>{$Think.server.server_software}</td>
				</tr>
				<tr>
					<td class="bodyTd1">网站已用空间大小</td>
					<td id="Info6" class="bodyTd1">
						<div style="float:left;"><img src="/static/admin/images/loading.gif" alt="正在载入" class="mid"> Loading...</div>
						<button type="button" onclick="clearTemp()" style="float:right;">清理缓存</button>
					</td>
				</tr>
				<tr>
					<td>网站版权所属</td>
					<td>
						<span id="Info7" runat="server" enableviewstate="false"></span>
						<span style="font-size:22px;">©</span> huwhois@163.com
					</td>
				</tr>
				<tr>
					<td class="bodyTd1">网站技术支持</td>
					<td class="bodyTd1">
						<a href="javascript:void(0)" title="网站建设专家" target="_blank">huwhois@163.com</a>
					</td>
				</tr>
			</tbody>
			<thead>
				<tr>
					<th colspan="2" scope="col">客户端信息</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>当前使用的操作系统</td>
					<td>{php}echo get_os();{/php}</td>
				</tr>
				<tr>
					<td>当前使用的浏览器</td>
					<td>{php}echo browse_info();{/php}</td>
				</tr>
			</tbody>
		</table>
		<table class="table table-border table-bordered table-bg mt-20" style="min-width:540px;max-width:50%;float:left;margin-left:2%;">
			<thead>
				<tr>
					<th colspan="4" scope="col">最近登陆记录</th>
				</tr>
				<tr>
					<th class='text-c' width="10%">序号</th>
					<th class='text-c' width="30%">登陆时间</th>
					<th class='text-c' width="20%">登陆IP</th>
					<th class='text-c' width="20%">浏览器</th>
				</tr>
			</thead>
			<tbody>
				{foreach $lgdata as $key=>$val}
				<tr>
					<td class='text-c'>{$key + 1}</td>
					<td>{$val.time|date="Y-m-d H:i:s", ###}</td>
					<td>{$val.ip|inet_ntoa}</td>
					<td>{$val.browser}</td>
				</tr>
				{/foreach}
			</tbody>
		</table>
	</article>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
	function modify(obj, field) {
		$("#" + field).attr('disabled', false);
		$("#" + field).focus();
		$("." + field).css('display', 'inline');
		$(obj).css('display', 'none');
	}

	function do_modify(obj, field) {
		var value = $("#" + field).val();

		$.post('{:url("/admin_user/modify")}', {
			'value': value,
			'field': field
		}, function (data) {
			if (data.code == 2) {
				layer.msg(data.msg, {
					icon: 1,
					time: 1000
				});
				$("#" + field).attr('disabled', true);
				$("." + field).css('display', 'none');
				$(obj).prevAll(".btn-primary").css('display', 'inline');
			} else {
				layer.msg(data.msg, {
					icon: 5,
					time: 1000
				});
				return false;
			}
		}, 'json');
	}

	function cancle(obj, field) {
		$("#" + field).attr('disabled', true);
		if (field == 'email') {
			$("#" + field).val("{$data.email}");
		} else {
			$("#" + field).val("{$data.pen_name}");
		}
		$("." + field).css('display', 'none');
		$(obj).prevAll(".btn-primary").css('display', 'inline');
	}

	function clearTemp() {
		$.post("{:url('/clearTemp')}", '', function(data) {
			if (data.code==2) {
				layer.msg(data.msg, {
					icon: 1,
					time: 2000
				});
				ajax_getSiteSize();
			} else {
				layer.msg(data.msg, {
					icon: 5,
					time: 2000
				});
			}
		}, 'json');
	}

	function ajax_getSiteSize() {
		$.post("{:url('/getSiteSize')}", '', function(data) {
			if (data.code==2) {
				$('#Info6 div').html(data.size);
			}
		}, 'json');
	}

	ajax_getSiteSize();
</script>
<!--请在上方写此页面业务相关的脚本-->